/*
 * \file DetailsWidget.cpp
 *
 * \date Created on: Jan 21, 2009
 * \author sarah
 */

#include "DetailsWidget.h"

#include <QTextBrowser>
#include <QPlainTextEdit>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>

#include <DndData/CharacterData.h>

DetailsWidget::DetailsWidget(CharacterData *data, QWidget *parent)
    : QWidget(parent)
    , mText(new QPlainTextEdit(this))
    , mLineEdit(new QLineEdit(this))
    , mData(data)
{
    QBoxLayout *layout = new QVBoxLayout();
    QBoxLayout *hLayout = new QHBoxLayout();
    hLayout->addWidget(new QLabel(tr("Character Name")));
    hLayout->addWidget(mLineEdit);
    layout->addWidget(new QLabel(tr("Character details, habits, dress")));
    layout->addLayout(hLayout);
    layout->addWidget(mText);
    setLayout(layout);
    connect(mText, SIGNAL(textChanged()),
            this, SLOT(updateDetails()));
    connect(mLineEdit, SIGNAL(textChanged(const QString &text)),
            this, SLOT(updateName()));
}

DetailsWidget::~DetailsWidget()
{
}

void DetailsWidget::updateDetails()
{
    mData->mDetails = mText->document()->toPlainText();
}

void DetailsWidget::updateName(const QString &text)
{
    mData->setTitle(text);
}
